/**
 * A very simple product editor
 */
'use strict';
var Product = require('../../models/productModel');

module.exports = function (router) {

        /**
         * Retrieve a list of all products for editing.
         */
        router.get('/', function (req, res) {

                Product.find(function (err, prods) {
                        if (err) {
                                console.log(err);
                        }
                        prods.forEach(function(prod) {
                                prod.prettyPrice = prod.prettyPrice();
                        });
                        var model =
                        {
                                products: prods
                        };
                        res.render('products', model);
                });

        });
};
